package com.akmedia.lacommunity.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;
import org.springframework.data.elasticsearch.annotations.*;

import java.time.LocalDateTime;

/**
 * @author ZJL
 * @date 2025/5/21
 * 随笔实体
 */
@Document(indexName = "eassy_index",createIndex = false)
@Mapping
public class Eassy {
    @Id
    private Integer eid; // 对应 mapping 中的 integer 类型

    @Field(type = FieldType.Text, analyzer = "ik_max_word") // 显式指定：text 类型 + IK 分词
    private String title;

    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String content;

    /**
     * 发送随笔的用户
     */
    private User user;
    /**
     * 随笔类型
     */
    private ContentType contentType;
    /**
     * 随笔状态
     */
    private Integer status;
    /**
     * 随笔发布时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createTime;

    public Eassy() {
    }

    public Eassy(Integer eid, String title, String content, User user, ContentType contentType, Integer status, LocalDateTime createTime) {
        this.eid = eid;
        this.title = title;
        this.content = content;
        this.user = user;
        this.contentType = contentType;
        this.status = status;
        this.createTime = createTime;
    }

    public Integer getEid() {
        return eid;
    }

    public void setEid(Integer eid) {
        this.eid = eid;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public ContentType getContentType() {
        return contentType;
    }

    public void setContentType(ContentType contentType) {
        this.contentType = contentType;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }
}

